h2{
backgound-color: lightblue
}
---
title: "Creating images with R"
subtitle: "with a little bit of magick"
author: "Qintong Li"
date: "2023-03-13"
output:
html_document: default
pdf_document: default
---
This is a funny meme made by Elon Musk’s shocked face and Donald Trump’s smile face.
My Meme
library(magick)
# First picture
elon_musk <- image_read("https://i.insider.com/5d10a8a597ad7650f7026ef2?width=1000&format=jpeg&auto=webp") %>%
image_resize("250x250!") # Resize
# Second picture
donald_trump <- image_read("https://makeameme.org/media/templates/250/donald-trump.jpg") %>%
image_resize("250x250!") # Resize
# Edit the text
text1 <- image_blank(width = 250, height = 250, color = "purple") %>%
image_annotate(text = "Man you\n serious?", color = "yellow", font = 'Times', size = 45, location = "+50+80") # Annotation
text2 <- image_blank(width = 250, height = 250, color = "grey") %>%
image_annotate(text = "Yes I am\n serious", color = "red", font = 'Times', size = 45, location = "+50+80") # Annotation
# First Meme
are_you <- image_append(c(text1, elon_musk))
# Second Meme
yes_I_am <- image_append(c(donald_trump,text2))
# Appending two memes together
meme <- image_append(stack = TRUE, c(are_you, yes_I_am)) %>%
image_resize("500x500!")
# Storage meme
image_write(meme, "my_meme.png")
This is an animated GIF that expresses my emotion of seeing different type of cars.
My Animation
library(magick)
# First meme
euros <- image_read("https://www.lamborghini.com/sites/it-en/files/DAM/lamborghini/facelift_2019/model_detail/few_off/sian_rds/2022/06_20/gallery/sian_rds_05.jpg") %>%
image_resize("600x300!") %>%
image_annotate(text = "Me when I\n see euros", font = 'Georgia', color = "yellow", size = 55)
# Second meme
say_no <- image_read("https://i.kym-cdn.com/entries/icons/original/000/026/779/drake.jpg") %>%
image_crop("650x700+130") %>%
image_resize("600x300!")
# Third meme
jdm <- image_read("https://i0.wp.com/ideal.media/wp-content/uploads/2021/02/nissan-r32-kyline-gtr.jpg?w=1920&ssl=1") %>%
image_crop("1700x1500+630+400") %>%
image_resize("600x300!") %>%
image_annotate(text = "Me when I\n see JDMs", font = 'Georgia', color = "orange", size = 55)
# Forth meme
nice <- image_read("https://img.doutuwang.com/2020/04/20200416021424_HpeCYQ.jpg") %>%
image_resize("600x300!")
# Create frames
frame_1 <- image_morph(c(euros, say_no), fps = 10)
frame_2 <- image_morph(c(jdm, nice), fps = 10)
# Create animations
gif <- image_animate(c(frame_1, frame_2), fps = 10) %>%
image_write("my_animation.gif") # Storage GIF